BASEDIR = $(shell cd ../.. && pwd)

MODSDIR = $(BASEDIR)/01-modules
LIBSDIR = $(BASEDIR)/03-libraries

CPPFLAGS = -I$(LIBSDIR)/openssl-1.0.0g/include \
           -I$(LIBSDIR)/libsqlite3     \
           -I$(MODSDIR)/logger/include \
           -I$(MODSDIR)/database/include

LDFLAGS  = -L$(LIBSDIR)/openssl-1.0.0g -lcrypto -L$(LIBSDIR)/libsqlite3 -lcppsqlite3

SRCS = testdatabase.cpp \
  $(MODSDIR)/logger/src/PopupDefaultLogger.cpp \
  $(MODSDIR)/database/src/PopupSqlite3Database.cpp

EXE = testdatabase

all: $(EXE) test

$(EXE) : $(SRCS)
	g++ $^ -o $@ $(CPPFLAGS) $(LDFLAGS)

clean:
	rm -f $(EXE) popup.db

popup.db: sqlite.cmd
	sqlite3 -init popup.sqlite $@ < sqlite.cmd

sqlite.cmd:
	echo ".exit" > $@

test: $(EXE) popup.db
	LD_LIBRARY_PATH=$(LIBSDIR)/libsqlite3 ./$(EXE) popup.db
